package com.hystrix;

import com.hystrix.command.HelloCommand;
import com.hystrix.command.RunCommand;
import rx.Observable;
import rx.Observer;


/**
 * 请先启动当前项目的Spirng Boot
 * Created by earl on 2018/4/28.
 */
public class TestCommand {

        public static void main(String [] args) throws InterruptedException {
            testCommand();
        }

        //测试正常的http服务
        public static  void testCommand() throws InterruptedException {

            RunCommand execute = new RunCommand(" 命令execute ");
            execute.execute();

            RunCommand queue = new RunCommand(" 命令queue ");
            queue.queue();

            RunCommand observe = new RunCommand(" 命令observe ");
            observe.observe();

            RunCommand toObservable = new RunCommand(" 命令toObservable");
            //调用toObservable方法，命令不会马上执行
            Observable<String> ob = toObservable.toObservable();
            ob.subscribe(new Observer<String>() {

                @Override
                public void onCompleted() {
                    System.out.println("    命令执行完成");
                }

                @Override
                public void onError(Throwable e) {
                }

                @Override
                public void onNext(String t) {
                    System.out.println("    命令执行结果：" + t);
                }

            });
            Thread.sleep(100);
        }


}
